﻿using AnyLink.Domain.Enums;
using Newtonsoft.Json;
using SqlSugar;

namespace AnyLink.Domain.Entities.System
{
    /// <summary>
    /// 操作日志记录
    /// </summary>
    [SugarTable("sys_oper_log", TableDescription = "操作日志记录", IsDisabledUpdateAll = true)]
    public class SysOperLog : IPrimaryKeyEntity<long>
    {
        /// <summary>
        /// 日志主键
        /// </summary>
        [SugarColumn(ColumnName = "oper_id", IsPrimaryKey = true, ColumnDescription = "日志主键")]
        [JsonProperty(propertyName: "operId")]
        public long Id { get; set; }

        /// <summary>
        /// 模块标题
        /// </summary>
        [SugarColumn(ColumnName = "title", ColumnDataType = "VARCHAR(50)", ColumnDescription = "模块标题", IsNullable = true)]
        public string Title { get; set; }

        /// <summary>
        /// 业务类型（0其它 1新增 2修改 3删除）
        /// </summary>
        [SugarColumn(ColumnName = "business_type", ColumnDescription = "业务类型（0其它 1新增 2修改 3删除）", IsNullable = true)]
        public BusinessTypeEnum BusinessType { get; set; }

        /// <summary>
        /// 方法名称
        /// </summary>
        [SugarColumn(ColumnName = "method", ColumnDataType = "VARCHAR(100)", ColumnDescription = "方法名称", IsNullable = true)]
        public string Method { get; set; }

        /// <summary>
        /// 请求方式
        /// </summary>
        [SugarColumn(ColumnName = "request_method", ColumnDataType = "VARCHAR(10)", ColumnDescription = "请求方式", IsNullable = true)]
        public string RequestMethod { get; set; }

        /// <summary>
        /// 操作类别（0其它 1后台用户 2手机端用户）
        /// </summary>
        [SugarColumn(ColumnName = "operator_type", ColumnDescription = "操作类别（0其它 1后台用户 2手机端用户）", IsNullable = true)]
        public OperatorTypeEnum OperatorType { get; set; }

        /// <summary>
        /// 操作人员
        /// </summary>
        [SugarColumn(ColumnName = "oper_name", ColumnDataType = "VARCHAR(50)", ColumnDescription = "操作人员", IsNullable = true)]
        public string OperName { get; set; }

        /// <summary>
        /// 部门名称
        /// </summary>
        [SugarColumn(ColumnName = "dept_name", ColumnDataType = "VARCHAR(50)", ColumnDescription = "部门名称", IsNullable = true)]
        public string DeptName { get; set; }

        /// <summary>
        /// 请求URL
        /// </summary>
        [SugarColumn(ColumnName = "oper_url", ColumnDataType = "VARCHAR(255)", ColumnDescription = "请求URL", IsNullable = true)]
        public string OperUrl { get; set; }

        /// <summary>
        /// 主机地址
        /// </summary>
        [SugarColumn(ColumnName = "oper_ip", ColumnDataType = "VARCHAR(128)", ColumnDescription = "主机地址", IsNullable = true)]
        public string OperIp { get; set; }

        /// <summary>
        /// 操作地点
        /// </summary>
        [SugarColumn(ColumnName = "oper_location", ColumnDataType = "VARCHAR(255)", ColumnDescription = "操作地点", IsNullable = true)]
        public string OperLocation { get; set; }

        /// <summary>
        /// 请求参数
        /// </summary>
        [SugarColumn(ColumnName = "oper_param", ColumnDataType = "VARCHAR(2000)", ColumnDescription = "请求参数", IsNullable = true)]
        public string OperParam { get; set; }

        /// <summary>
        /// 返回参数
        /// </summary>
        [SugarColumn(ColumnName = "json_result", ColumnDataType = "VARCHAR(2000)", ColumnDescription = "返回参数", IsNullable = true)]
        public string JsonResult { get; set; }

        /// <summary>
        /// 操作状态（0正常 1异常）
        /// </summary>
        [SugarColumn(ColumnName = "status", ColumnDescription = "操作状态（0正常 1异常）", IsNullable = true)]
        public StatusEnum Status { get; set; }

        /// <summary>
        /// 错误消息
        /// </summary>
        [SugarColumn(ColumnName = "error_msg", ColumnDataType = "VARCHAR(2000)", ColumnDescription = "错误消息", IsNullable = true)]
        public string ErrorMsg { get; set; }

        /// <summary>
        /// 操作时间
        /// </summary>
        [SugarColumn(ColumnName = "oper_time", ColumnDescription = "操作时间", IsNullable = true)]
        public DateTime OperTime { get; set; }

        /// <summary>
        /// 消耗时间
        /// </summary>
        [SugarColumn(ColumnName = "cost_time", ColumnDescription = "消耗时间", IsNullable = true)]
        public long CostTime { get; set; }
    }
}